cd "${mystart}/Simulated data\Calibration/Benchmark Data/"


* Table 48, right panel 
* WEALTH TERCILES AND HEALTH DISTRIBUTION
qui{
clear
use "Data files/Benchmark.dta"
keep if age>55 & age<61
xtile w_group1=assets if education==1 ,n(3)
xtile w_group2=assets if education==2 ,n(3)
xtile w_group3=assets if education==3 ,n(3)

gen w_group=w_group1 if  education==1
replace w_group=w_group2 if  education==2
replace w_group=w_group3 if  education==3

label var w_group "Wealth Tercile"

  label define tercile1 1 "1st" 2 "2nd"  3 "3rd"
  label value w_group tercile1
  
  
  table  education H     ,  statistic(fvpercent w_group)   nformat(%5.1f)  nototals

  
  table  (education w_group)     ,  statistic(fvpercent H)   nformat(%5.1f)  nototals
collect title "Health distribution within wealth terciles, by education, ages 56-60, Model"
collect export "${out_tables}/HRS_H_wealth.tex", tableonly replace
}


* Table 54
* Assets statistics
qui{
clear
use "Data files/Benchmark.dta"
set more off

keep if age>=55 & age<=60
gen I_zero_assets=1 if assets<10000
replace I_zero_assets=0 if assets>=10000

gen assets_nn=assets/1000 
replace assets_nn=. if assets<10

label var I_zero_assets "% Negligible"
label var assets_nn "If non-negligible"
table  (education) if age>=55 & age<61 ,  statistic( mean I_zero_assets) statistic(p25 assets_nn)  statistic(median assets_nn) statistic(p75 assets_nn) nototals nformat(%5.2f)  
collect title "Assets statistics, ages 55-60, Model"
collect export "${out_tables}/Wealth_zero_assets_sim.tex", tableonly replace

}



